﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Intorise.LLPM.Model;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Database db = new Database();
            //Department department = new Department { ID = Guid.NewGuid(), Name = "人事部" };
            //db.AddToDepartment(department);
            //db.SaveChanges();

            //var departments = db.Department.ToList();
            //departments.ForEach(x =>
            //{
            //    Console.WriteLine("ID:" + x.ID + "\tName:" + x.Name);
            //});

            //Console.ReadLine();

            //Role role = new Role { ID = Guid.NewGuid(), Name = "系统管理员" };
            //db.AddToRole(role);
            //User user = new User { ID = Guid.NewGuid(), Account = "test", Password = "123", IsValid = true };
            //db.AddToUser(user);
            //RoleOfUser rou = new RoleOfUser { ID = Guid.NewGuid(), RID = role.ID, UID = user.ID };
            //db.AddToRoleOfUser(rou);

            //db.SaveChanges();
            //User.Register("admin", "12345678");
            User user = User.Login("admin", "12345678");
            if (user == null)
            {
                Console.WriteLine("用户名或密码错误！");
            }
            else
            {
                Console.WriteLine("登录成功！");
                Console.WriteLine("ID:" + user.ID + "\tAccount:" + user.Account);
            }
            db.User.ToList().ForEach(x =>
            {
                Console.WriteLine("ID:" + x.ID + "\tAccount:" + x.Account);
            });
            Console.ReadLine();
        }
    }
}
